package com.rqstmx97.playerpos.mcbukkit.kr;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.Bukkit;
import org.bukkit.Location;

public class GetPlayerPosCommand implements CommandExecutor {
	private final GetPlayerPos plugin;
	
	public GetPlayerPosCommand(GetPlayerPos instance) {
		plugin =  instance;
	}
	
	public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
		
		Player player = (Player) sender;
		Player player2 = Bukkit.getServer().getPlayer(args[0]);
		Location location = player2.getLocation();
		double playerX = location.getX();
		double playerY = location.getY();
		double playerZ = location.getZ();
		
		double Xpos = Double.parseDouble(String.format("%.0f", playerX));
		double Ypos = Double.parseDouble(String.format("%.0f", playerY));
		double Zpos = Double.parseDouble(String.format("%.0f", playerZ));
		
		player.sendMessage(args[0] + "'s current location");
		player.sendMessage("X : " + Xpos + " Y : " + Ypos + " Z : " + Zpos);
		
		if(args.length > 0) {
			if(args[0].equalsIgnoreCase("version")) {
				player.sendMessage("GetPlayerPos plugin version '1.0.0.0_dev01' \nGetPlayerPos plugin build 1.0.0.0_dev01-b5");
			}
		}
		
		else if(args.length > 4) {
			System.out.println("Syntax Error : Too many arguments");
			player.sendMessage("Syntax Error : Too many arguments");
		}
		return true;
	}

}
